public class Login {

	private String user;
	private String pass;
	private int permission;
	private int userID;
	
	//Constructor for the Login class
	Login(){

	}
	
	//authenticates 
	public String authenticate(){
			//Start authentication
			String msg;
			permission=0;
				boolean check=false;
				//Check credentials in the database
				check=AbsDatabase.checkCreds(user,pass);
				
				//credentials accepted
				if(check==true){
					msg="\nLogin Successful.\n";
					permission=AbsDatabase.getPermissions(user);
					userID=AbsDatabase.getUserID(user);
				} 
				//credentials rejected
				else {
					msg="\nLogin failed, please try again.\n";
				}
			return msg;
	}

	//sets the username for the login
	public void setUser(String username){
		user=username;
	}
	
	public void setPass(String password){
		pass=password;
	}
	
	//returns permission level
	public int getPermissions(){
		return permission;
	}
	
	//returns user ID
	public int getUserID(){
		return userID;
	}
}
